home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tclsrc / convlib.tcl < prev    next >
Encoding:
Text File  |  1992-11-07  |  1.9 KB  |  54 lines

  1. #
  2. # convlib.tcl --
  3. #
  4. #     Convert Ousterhout style tclIndex files and associated libraries to a
  5. # package library.
  6. #------------------------------------------------------------------------------
  7. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  8. #
  9. # Permission to use, copy, modify, and distribute this software and its
  10. # documentation for any purpose and without fee is hereby granted, provided
  11. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  12. # Mark Diekhans make no representations about the suitability of this
  13. # software for any purpose.  It is provided "as is" without express or
  14. # implied warranty.
  15. #------------------------------------------------------------------------------
  16. # $Id: convlib.tcl,v 2.0 1992/10/16 04:51:53 markd Rel $
  17. #------------------------------------------------------------------------------
  18. #
  19.  
  20. #@package: TclX-convertlib convert_lib
  21.  
  22. proc convert_lib {tclIndex packageLib {ignore {}}} {
  23.     if {[file tail $tclIndex] != "tclIndex"} {
  24.         error "Tail file name numt be `tclIndex': $tclIndex"}
  25.     set srcDir [file dirname $tclIndex]
  26.  
  27.     if {[file extension $packageLib] != ".tlib"} {
  28.         append packageLib ".tlib"}
  29.  
  30.     # Build an array addressed by file name containing all of the procs
  31.     # defined in that file.
  32.  
  33.     set tclIndexFH [open $tclIndex r]
  34.     while {[gets $tclIndexFH line] >= 0} {
  35.         if {([cindex $line 0] == "#") || ([llength $line] != 2)} {
  36.             continue}
  37.         if {[lsearch $ignore [lindex $line 1]] >= 0} {
  38.             continue}
  39.         lappend entryTable([lindex $line 1]) [lindex $line 0]
  40.     }
  41.     close $tclIndexFH
  42.  
  43.     set libFH [open $packageLib w]
  44.     foreach srcFile [array names entryTable] {
  45.         set srcFH [open $srcDir/$srcFile r]
  46.         puts $libFH "#@package: $srcFile $entryTable($srcFile)\n"
  47.         copyfile $srcFH $libFH
  48.         close $srcFH
  49.     }
  50.     close $libFH
  51.     buildpackageindex $packageLib
  52. }
  53.